<% layout('/layouts/default.html', {title: '综合查询', libs: ['dataGrid']}){ %>
<div class="ui-layout-center">
<div class="main-content">
    <div class="box box-main">
        <div class="box-header">
         <#form:form id="searchForm" model="${dcSupTaskInfo}" action="${ctx}/query/ComPreHenceQuery/list" method="post" class="form-inline"
            data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
            <div style="float: right">
                <div class="form-group">
                    <label class="control-label">${text('任务年度')}：</label>
                    <div class="control-inline width-120">
                        <#form:select path="taskYear" items="${yearList}" blankOption="true" data-placeholder="请选择" itemLabel="yearLabel" itemValue="yearValue" class="form-control width-120" />
                    </div>
                </div>
                <!--此处为导出时选择的列的插入位置-->
                <#form:hidden path="exportColumn" />
                <div class="form-group">
                    <label class="control-label">${text('任务标题')}：</label>
                    <div class="control-inline width-160">
                        <#form:input path="taskTitle" maxlength="200" class="form-control width-160" placeholder="请输入任务标题"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">${text('任务类型')}：</label>
                    <div class="control-inline width-160">
                        <#form:select path="taskTypeCode" items="${dicts}" blankOption="true" data-placeholder="请选择任务类型" itemLabel="dictLabel" itemValue="dictValue" class="form-control width-160 " />
                    </div>
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-primary btn-sm closeTab">${text('查询')}</button>
                    <button onclick="cz();" class="btn btn-default btn-sm closeTab">${text('重置')}</button>
                    <button id="changeIcon" type="button" class="btn btn-default btn-sm btnFormMore">${text('高级查询')}<i class="fa fa-angle-double-down" id="changeIcon1"></i></button>
<!--                    <button id="changeIcon2" type="button" class="btn btn-default btn-sm btnFormMore">${text('导出')}<i class="fa fa-angle-double-down" id="changeIcon3"></i></button>-->
                    <button type="button" class="btn btn-default btn-sm " onclick="openExport()">${text('导出')}</button>
                </div>
                <div class="form-more">
                    <div id="exportCss" style="display: none;">
                        <div style="float: right">
                            <div class="form-group">
                            <a href="#" class="btn btn-default" id="btnExport"><i class="glyphicon glyphicon-export"></i> ${text('导出')}</a>
                            <!--<a href="#" class="btn btn-default loading1" id="btnExportPiShi"><i class="fa fa-file-excel-o"></i> ${text('批示导出')}</a>
                            <a href="#" class="btn btn-default loading1" id="btnExportExcel"><i class="fa fa-file-excel-o"></i> ${text('市政府重点工作导出')}</a>-->
                            </div>
                        </div>
                    </div>
                    <div id="chaXunCss" style="display: none;">
                    <div style="float: right">
                        <div class="form-group">
                            <label class="control-label">${text('督办字号')}：</label>
                            <div class="control-inline width-120">
                                <#form:input path="messageNumber" maxlength="50" class="form-control width-120" placeholder="请输入督办字号"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label">${text('任务内容')}：</label>
                            <div class="control-inline width-160">
                                <#form:input path="taskContent" maxlength="200" class="form-control width-160" placeholder="请输入任务内容"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label">${text('牵头领导')}：</label>
                            <div class="control-inline width-120">
                                <#form:select path="taskLeader" items="${userList!}" blankOption="true" data-placeholder="请选择牵头领导" itemLabel="userName" itemValue="userCode" class="form-control width-120"/>
                                <#form:hidden path="taskLeaderName"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label">${text('任务进度')}：</label>
                            <div class="control-inline width-120">
                                <#form:select path="taskProgress" dictType="dc_task_progress" blankOption="true" data-placeholder="请选择任务进度" class="form-control width-120"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label">${text('任务分类')}：</label>
                            <div class="control-inline width-120">
                                <% var items = [{label:'单位发布的任务',value:'2'},{label:'我发布的任务',value:'1'},{label:'单位接收的任务',value:'4'},{label:'我待办的任务',value:'3'}]; %>
                                <#form:select path="taskCreateType" items="${items!}" itemLabel="label" itemValue="value" blankOption="true" data-placeholder="请选择任务进度" class="form-control width-120" defaultValue="2"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label">${text('牵头单位')}：</label>
                            <div class="control-inline width-160">
                                <#form:input path="taskLeaderOrgName" maxlength="200" class="form-control width-160" placeholder="请输入牵头单位"/>
                            </div>
                        </div>
                    </div>
                    </div>
                </div>
            </div>
            </#form:form>
        </div>
        <div class="box-body">
            <table id="dataGrid"></table>
            <div id="dataGridPage"></div>
        </div>
    </div>
</div>
<% } %>

<script>
    //重置
    function cz(){
        searchForm.reset();
        $('#dataGrid').dataGrid('reloadGrid');
    }

    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        dataGridPage: $('#dataGridPage'),
        sortableColumn: false, // 列表不允许排序
        columnModel: [
            {header:'${text("主键")}', name:'id', index:'a.id', width:150, align:"left", hidden:true},
            {header:'${text("督办字号")}', name:'messageNumber', index:'a.message_number', width:100, align:"left"},
            {header:'${text("任务标题")}', name:'taskTitle', index:'a.task_title', width:150, align:"left"},
            {header:'${text("任务类型")}', name:'taskTypeName', index:'a.task_type_name', width:150, align:"left"},
            {header:'${text("任务内容")}', name:'taskContent', index:'a.task_content', width:150, align:"left", formatter: function(val, obj, row, act){
                    return '<a href="${ctx}/taskdeploy/dcSupTaskInfo/detailForm?id='+row.taskId+'" class="btnList" data-title="${text("督办任务信息")}">'+(val||'暂无内容')+'</a>';
                }},
            {header:'${text("牵头领导")}', name:'taskLeaderName', index:'a.task_leader_name', width:150, align:"left"},
            {header:'${text("牵头责任单位")}', name:'taskLeaderOrgName', index:'a.task_leader_org_name', width:150, align:"left"},
            {header:'${text("任务状态")}', name:'taskStatus', index:'a.task_status', width:150, align:"center",formatter: function(val, obj, row, act){return js.getDictLabel(${@DictUtils.getDictListJson('dc_task_status')}, val, '${text("未知")}', true);}},
            // {header:'${text("排序编号")}', name:'sortNum', index:'a.sort_num', width:50, align:"center", formatter: function(val, obj, row, act){
            //     return '<a href="javascript:void(0);" onclick="changeSortNum(\''+row.id+'\',\''+row.sortNum+'\');" title="${text("修改排序编号")}">'+(val||'-')+'</a>';
            //     }},
            {header:'${text("操作")}', name:'actions', width:100,align:"center", formatter: function(val, obj, row, act){
                    var actions = [];
                    actions.push('<a href="${ctx}/action/dcSupTaskAction/listOrg1?remarks1=1&taskId='+row.id+'" class="btn btn-primary btn-xs btnList" title="${text("查看反馈")}" ><span>查看反馈</span></a>&nbsp;');
                    return actions.join('');
                }}
        ],
        // 加载成功后执行事件
        ajaxSuccess: function(data){
        }
    });

    // // 导出
    // $('#btnExport').click(function(){
    //     js.ajaxSubmitForm($('#searchForm'), {
    //         url:'${ctx}/query/ComPreHenceQuery/exportData',
    //         downloadFile:true
    //     });
    // });

    // 修改排序编号
    function changeSortNum(taskId, sortNum) {
        if(sortNum == "undefined"){
            sortNum = "";
        }
        js.layer.open({
            type:2,
            title:['修改任务排序编号'],
            area:['800px','300px'],
            scrollbar: true,
            shadeClose: false,
            content:"${ctx}/query/ComPreHenceQuery/changeSortNumForm?taskId="+taskId+"&sortNum="+sortNum,
            btn: ['<i class="fa fa-check"></i> ${text("导出")}',
                '<i class="fa fa-remove"></i> ${text("关闭")}'],
            btn1:function (index,layero) {

            },
            end:function () {
                $('#dataGrid').dataGrid('refresh', 1, 20);
            }
        });
    }

    // 导出
    $('#btnExport').click(function(){
        js.layer.open({
            type: 1,
            area: ['400px'],
            title: '${text("导出任务数据")}',
            resize: false,
            scrollbar: true,
            content: js.template('importTpl2'),
            success: function(layero, index){
                layero.find('input[type="checkbox"]').iCheck();
            },		btn: ['<i class="fa fa-check"></i> ${text("确定")}',
                '<i class="fa fa-remove"></i> ${text("关闭")}'],
            btn1: function(index, layero){
                // 获取选中的列
                let exportColumn=[];
                layero.find("input[name='exportColumn']:checkbox").each(function(){
                    if(true == $(this).is(':checked')){
                        exportColumn.push($(this).val());
                    }
                });
                // 将选中的列，放到查询条件中
                $('#exportColumn').val(exportColumn)

                js.ajaxSubmitForm($('#searchForm'), {
                    url:'${ctx}/query/ComPreHenceQuery/exportData',
                    downloadFile:true
                });
            }
        });
    });
    $('#btnExport2').click(function(){
        js.layer.closeAll();
    })
    // 导出细化分解word
    $('#btnExportPiShi').click(function(){
        js.ajaxSubmitForm($('#searchForm'), {
            url:'${ctx}/query/ComPreHenceQuery/btnExportPiShi',
            downloadFile:true
        });
    });
    // 导出细化分解excel
    $('#btnExportExcel').click(function(){
        js.ajaxSubmitForm($('#searchForm'), {
            url:'${ctx}/query/ComPreHenceQuery/exportRefineExcel',
            downloadFile:true
        });
    });
//点击高级查询改变样式
    var num = 0;
    $('#changeIcon').click(function(){
        if(num1==1){//打开导出点击查询后事件
            num1=0//导出开关置为0
            $('#changeIcon3').removeClass("fa fa-angle-double-up")
            $('#changeIcon3').addClass("fa fa-angle-double-down")//导出关闭箭头
            return
        }
        if(num==0){
            $('#changeIcon1').removeClass("fa fa-angle-double-down")
            $('#changeIcon1').addClass("fa fa-angle-double-up")//查询打开箭头
            $("#exportCss").css("display","none");//导出关闭
            $("#chaXunCss").css("display","block");//查询打开
            num=1;
        }else{
            $('#changeIcon1').removeClass("fa fa-angle-double-up")
            $('#changeIcon1').addClass("fa fa-angle-double-down")//查询关闭箭头
            $("#exportCss").css("display","block");//导出打开
            $("#chaXunCss").css("display","none");//查询关闭
            num=0;
        }
    })
    var num1 = 0;
    $('#changeIcon2').click(function(){
        if(num==1){//打开查询点击导出后事件
            num=0//查询开关置为0
            $('#changeIcon1').removeClass("fa fa-angle-double-up")
            $('#changeIcon1').addClass("fa fa-angle-double-down")//查询关闭箭头
            return
        }
        if(num1==0){
            $('#changeIcon3').removeClass("fa fa-angle-double-down")
            $('#changeIcon3').addClass("fa fa-angle-double-up")//导出打开箭头
            $("#exportCss").css("display","block");//导出打开
            $("#chaXunCss").css("display","none");//查询关闭
            num1=1;
        }else{
            $('#changeIcon3').removeClass("fa fa-angle-double-up")
            $('#changeIcon3').addClass("fa fa-angle-double-down")//导出关闭箭头
            $("#exportCss").css("display","none");//导出隐藏
            $("#chaXunCss").css("display","block");//查询显示
            num1=0;
        }
    })
    $('.closeTab').click(function(){
    num=0//查询开关置为0
    $('#changeIcon1').removeClass("fa fa-angle-double-up")
    $('#changeIcon1').addClass("fa fa-angle-double-down")//查询关闭箭头
    num1=0//导出开关置为0
    $('#changeIcon3').removeClass("fa fa-angle-double-up")
    $('#changeIcon3').addClass("fa fa-angle-double-down")//导出关闭箭头
});
    //导出加载框
    $('.loading1').click(function(){
        js.loading("正在导出，请勿重复操作...");
        js.closeLoading(3000);
    })
    function openExport(){
        js.layer.open({
            type:0,
            title:['导出'],
            area:['450px','160px'],
            scrollbar: true,
            shadeClose: false,
            content:"请选择文件导出类型",
            btnAlign: 'c',
            btn: ['<i class="glyphicon glyphicon-export"></i> ${text("默认导出")}'/*,
                '<i class="glyphicon glyphicon-export"></i> ${text("批示导出")}',
                '<i class="glyphicon glyphicon-export"></i> ${text("市政府重点工作导出")}'*/],
            btn1:function (index,layero) {
                js.layer.open({
                    type: 1,
                    area: ['400px'],
                    title: '${text("导出任务数据")}',
                    resize: false,
                    scrollbar: true,
                    content: js.template('importTpl2'),
                    success: function(layero, index){
                        layero.find('input[type="checkbox"]').iCheck();
                    },		btn: ['<i class="fa fa-check"></i> ${text("确定")}',
                        '<i class="fa fa-remove"></i> ${text("关闭")}'],
                    btn1: function(index, layero){
                        // 获取选中的列
                        let exportColumn=[];
                        layero.find("input[name='exportColumn']:checkbox").each(function(){
                            if(true == $(this).is(':checked')){
                                exportColumn.push($(this).val());
                            }
                        });
                        // 将选中的列，放到查询条件中
                        $('#exportColumn').val(exportColumn)

                        js.ajaxSubmitForm($('#searchForm'), {
                            url:'${ctx}/query/ComPreHenceQuery/exportData',
                            downloadFile:true
                        });
                        js.loading("正在导出，请勿重复操作...");
                        js.closeLoading(3000);
                    }
                });
            },
            btn2:function (index,layero) {

                js.ajaxSubmitForm($('#searchForm'), {
                    url:'${ctx}/query/ComPreHenceQuery/btnExportPiShi',
                    downloadFile:true
                });
                js.loading("正在导出，请勿重复操作...");
                js.closeLoading(3000);
            },
            btn3:function (index,layero) {

                js.ajaxSubmitForm($('#searchForm'), {
                    url:'${ctx}/query/ComPreHenceQuery/exportRefineExcel',
                    downloadFile:true
                });
                js.loading("正在导出，请勿重复操作...");
                js.closeLoading(3000);
            },
            end:function () {

            }
        });
    }
</script>

<script id="importTpl2" type="text/template">
    <form id="inputForm2" action="${ctx}/query/ComPreHenceQuery/exportData" method="post" enctype="multipart/form-data"
          class="form-horizontal mt20 mb10" style="overflow:auto;max-height:200px;">
        <div class="row">
            <div class="col-xs-12 col-xs-offset-1">
                <div class="mt10 pt5">
					<span id="exportColumn" class="icheck" class="form-control required">
					<label><input type="checkbox" id="exportColumn1" name="exportColumn"  value="督办字号" class="form-control required" checked> 督办字号</label>
					<label><input type="checkbox" id="exportColumn2" name="exportColumn"  value="任务标题" class="form-control required" checked> 任务标题</label>
					<label><input type="checkbox" id="exportColumn3" name="exportColumn" value="任务类型" class="form-control required" checked> 任务类型</label>
					<label><input type="checkbox" id="exportColumn4" name="exportColumn" value="任务内容" class="form-control required" checked> 任务内容</label>
                    <label><input type="checkbox" id="exportColumn5" name="exportColumn" value="牵头领导" class="form-control required"> 牵头领导</label>
                    <label><input type="checkbox" id="exportColumn6" name="exportColumn" value="牵头责任单位" class="form-control required"> 牵头责任单位</label>
                    <label><input type="checkbox" id="exportColumn7" name="exportColumn" value="任务状态" class="form-control required"> 任务状态</label>
                    <label><input type="checkbox" id="exportColumn8" name="exportColumn" value="反馈内容" class="form-control required"> 反馈内容</label>
                    <label><input type="checkbox" id="exportColumn9" name="exportColumn" value="整理内容" class="form-control required"> 整理内容</label>
					<input type="hidden" name="!exportColumn" value=""/></span>
                </div>
                <span style="color:red" class="pull-left mt10">
                    ${text('提示：仅导出“xls”或“xlsx”格式文件！')}
                </span>
            </div>
        </div>
    </form>
</script>